﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Security.Permissions;
using ProtoBuf;

namespace Serialization
{
[ProtoContract]
    public class StringContainer
    {
        [ProtoMember(1)]
        private Dictionary<string, string> globalStrings
        {
            get;
            set;
        }

        public string getValue(string key)
        {
            string data;
            if (globalStrings.TryGetValue(key, out data))
            {
                return data;
            }
            else
            {
                return "!error";
            }
        }

        public void addValue(string value, string key)
        {
            globalStrings[key] = value;
        }

        public void removeValue(string key)
        {
            globalStrings.Remove(key);
        }

        public string[] getAllKeys()
        {
            string[] keys = new string[globalStrings.Keys.Count];
            globalStrings.Keys.CopyTo(keys, 0);
            return keys;
        }

        public StringContainer()
        {
            globalStrings = new Dictionary<string, string>();
        }
    }
}

